<?php

class ZFKiller_View_Helper_HeadMetaOpenGraph extends Zend_View_Helper_Placeholder_Container_Standalone {

	private $_fbAdmins = null;
	private $_ogTitle = null;
	private $_ogType = null;
	private $_ogUrl = null;
	private $_ogImage = null;
	private $_ogSiteName = null;

	public function headMetaOpenGraph() {
		return $this;
	}

	public function getFbAdmins() {
		return $this->_fbAdmins;
	}

	public function getFbScript() {
		if (null !== $this->_ogTitle) {
			?>
			<div id="fb-root"></div>
			<script>(function(d, s, id) {
				var js, fjs = d.getElementsByTagName(s)[0];
				if (d.getElementById(id)) return;
				js = d.createElement(s); js.id = id;
				js.src = "//connect.facebook.net/pt_BR/all.js#xfbml=1";
				fjs.parentNode.insertBefore(js, fjs);
			}(document, 'script', 'facebook-jssdk'));</script>
			<?php
		}
	}

	public function getOgImage() {
		return $this->_ogImage;
	}

	public function getOgSiteName() {
		return $this->_ogSiteName;
	}

	public function getOgTitle() {
		return $this->_ogTitle;
	}

	public function getOgType() {
		return $this->_ogType;
	}

	public function getOgUrl($encoded = false) {
		if ($encoded) {
			return urlencode($this->_ogUrl);
		}
		return $this->_ogUrl;
	}

	public function setFbAdmins($fbAdmins) {
		$this->_fbAdmins = $fbAdmins;
	}

	public function setOgImage($ogImage) {
		$this->_ogImage = $ogImage;
	}

	public function setOgSiteName($ogSiteName) {
		$this->_ogSiteName = $ogSiteName;
	}

	public function setOgTitle($ogTitle) {
		$this->_ogTitle = $ogTitle;
	}

	public function setOgType($ogType) {
		$this->_ogType = $ogType;
	}

	public function setOgUrl($ogUrl) {
		$this->_ogUrl = $ogUrl;
	}

	public function toString() {
		$r = '';
		if (null !== $this->_ogTitle) {
			$r .= '<meta property="og:title" content="' . $this->_ogTitle . '">' . PHP_EOL;
		}
		if (null !== $this->_ogType) {
			$r .= '<meta property="og:type" content="' . $this->_ogType . '">' . PHP_EOL;
		}
		if (null !== $this->_ogUrl) {
			$r .= '<meta property="og:url" content="' . $this->_ogUrl . '">' . PHP_EOL;
		}
		if (null !== $this->_ogImage) {
			$r .= '<meta property="og:image" content="' . $this->_ogImage . '">' . PHP_EOL;
		}
		if (null !== $this->_ogSiteName) {
			$r .= '<meta property="og:site_name" content="' . $this->_ogSiteName . '">' . PHP_EOL;
		}
		if (null !== $this->_fbAdmins) {
			$r .= '<meta property="fb:admins" content="' . $this->_fbAdmins . '">' . PHP_EOL;
		}

		return $r;

		// <meta property="fb:admins" content="100003255350014" />
	}

}